/**
 * 封装 axios 请求模块
 */
import axios from 'axios'
import jsonBig from 'json-bigint'
// import store from '@/store'
import router from '@/router'
import { Notify } from 'vant'
// const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZ2VudElkIjoiMzAwMCIsInRpbWVzdGFtcCI6MTcxMjY4MDE1NSwidXNlcklkIjozMjIwMTIyMn0.QOJ9rlpxLFjliCcWT77Dpv3IRqw3zV9CcekCiIIyBSM"
let token = localStorage.getItem("token")
if (!!token){
  token=token.replace("\"","").replace("\"","");
}
// axios.create 方法：复制一个 axios
const request = axios.create({

  baseURL: 'https://m.maizuo.com/gateway',
  headers: {
    'Host': 'm.maizuo.com',
    'Origin': 'https://m.maizuo.com',
    'Referer': 'https://m.maizuo.com/',
    'X-Client-Info': '{ "a": "3000", "ch": "1002", "v": "5.2.1", "e": "17126772682879303125565441", "bc": "110100" }',
    'Accept': 'application/json, text/plain, */*',
    // 'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
    // 'Accept-Encoding': 'gzip, deflate, br',
    'X-Token':token,
    'X-Requested-With': 'XMLHttpRequest',
    // 'Connection': 'keep-alive',
    // 'Referer': 'https://m.maizuo.com/v5/',
    'Cookie': `co=mzmovie; DEVICE_ID=17126772682879303125565441; _bl_uid=7jl72u10sI9jFLtgjqayxCRmm1d3; COOKIE_SERVICE_TIME=1712684520; gr_user_id=87041406-e549-4248-adbc-115f94850841; ac641e22637cd956_gr_session_id=547958cd-f189-442a-9833-c4d017b74f16; ac641e22637cd956_gr_last_sent_sid_with_cs1=547958cd-f189-442a-9833-c4d017b74f16; ac641e22637cd956_gr_last_sent_cs1=32201222; COOKIE_CITY_ID=110100; COOKIE_CITY_NAME=%E5%8C%97%E4%BA%AC; COOKIE_BUSINESS_CITY=110100; COOKIE_USER_INFO_HAS_PASSWORD=1; COOKIE_USER_INFO_HAS_PAY_PASSWORD=0; aliyungf_tc=13a241d61ced47a53de592f3dcf7022200f804d035d2954727f4393ce9f2712d; ac641e22637cd956_gr_session_id_sent_vst=547958cd-f189-442a-9833-c4d017b74f16; COOKIE_USER_ID=32201222; COOKIE_USER_NAME=maizuoiOh7yI8107; COOKIE_USER_MOBILE=18523008107; COOKIE_USER_X_TOKEN=${token}; COOKIE_USER_THIRD_OPENID=; COOKIE_USER_THIRD_TYPE=; acw_tc=5c72f887171268036582510004455507e55e731dbdc0095d770265150a38b5; ac641e22637cd956_gr_cs1=32201222`,
    // 'Sec-Fetch-Dest': 'empty',
    // 'Sec-Fetch-Mode': 'cors',
    // 'Sec-Fetch-Site': 'same-origin'
  }
})

/**
 * 配置处理后端返回数据中超出 js 安全整数范围问题
 */
request.defaults.transformResponse = [function (data) {
  try {
    return jsonBig.parse(data)
  } catch (err) {
    return {}
  }
}]


export default request
